import 'package:flutter/material.dart';
import 'package:huobi/model/homePage/xbb_cell_model.dart';
import 'package:huobi/views/jk/jk_text.dart';

class XbbCellWidget extends StatelessWidget {
  final XbbCellModel dataModel;
  final bool showBottomBorder;

  const XbbCellWidget({Key key, this.dataModel, this.showBottomBorder = true})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 60,
      padding: EdgeInsets.symmetric(horizontal: 16, vertical: 10),
      decoration: showBottomBorder
          ? BoxDecoration(
        border: Border(
          bottom: BorderSide(width: 0.2, color: Colors.white24),
        ),
      )
          : null,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Expanded(
            flex: 4,
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.end,
              children: [
                JKText(
                  data: "${dataModel.name}",
                  fontSize: 18,
                  color: Colors.white,
                  weight: FontWeight.bold,
                ),
              ],
            ),
          ),
          Expanded(
            flex: 6,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Expanded(
                  flex: 1,
                  child: JKText(
                    data: "${dataModel.price}",
                    fontSize: 14,
                    color: Colors.white,
                    weight: FontWeight.bold,
                    textAlign: TextAlign.right,
                  ),
                ),
                Expanded(
                  flex: 1,
                  child: Padding(
                    padding: EdgeInsets.only(left: 20),
                    child: Container(
                      padding: EdgeInsets.all(8),
                      decoration: BoxDecoration(
                        color: dataModel.amplitude >0 ? Colors.green : Colors.red,
                        borderRadius: BorderRadius.all(
                          Radius.circular(5),
                        ),
                      ),
                      child: JKText(
                        data: dataModel.amplitude >0 ? "+${dataModel.amplitude}%" : "${dataModel.amplitude}%",
                        fontSize: 14,
                        color: Colors.white,
                        weight: FontWeight.bold,
                        textAlign: TextAlign.center,
                      ),
                    ),
                  ),
                )
              ],
            ),
          )
        ],
      ),
    );
  }
}
